<template>
	<view class="page-content">
		<!-- 标题栏和状态栏占位符 -->
		<view class="titleNview-placing"></view>
		<view class="page-top">
			<image class="t-logo" src="/static/index/logo.png"></image>
		</view>
		
		<!--内容-->
		<scroll-view class="page-body" :scroll-top="scrollTop" scroll-y="true" @scrolltolower="loadmore()">
			<template v-if="datalist && datalist.length > 0 ">
				<block v-for="(item,index) in datalist" :key="index">
					<view class="box-li" @click="tohref(item.url,item.name)">
						<image class="box-img" :src="item.img" ></image>
					</view>
				</block>
				<!-- 上拉加载 -->
				<view class="det-con-more">
					<load-more :loadmore="load_more1"></load-more>
				</view>
			</template>
			<!--无数据-->
			<empty v-else no-full type="noData"></empty>
		</scroll-view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from "vuex";
	import {
		getWebDatas,
	} from '@/common/api.js';
	import loadMore from '@/components/uni-load-more/load-more.vue';
	export default {
		components: {
			loadMore
		},
		data() {
			return {
				scrollTop: 0,
				noData: false,
				load_more1: '', //下拉加载文字
				load_sta: false, //是否是加载状态
				datalist:[
					{
						name:'淘宝网',
						img:'/static/data-img/img-tb.png',
						url:'https://m.taobao.com'
					},{
						name:'天猫',
						img:'/static/data-img/img-tm.png',
						url:'https://m.tmall.com'
					},{
						name:'京东',
						img:'/static/data-img/img-jd.png',
						url:'https://www.jd.com'
					},{ 
						name:'淘宝网',
						img:'/static/data-img/img-am.png',
						url:'https://m.taobao.com'
					}
				],
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		onShow() {
			// 导航栏多语言
			uni.setNavigationBarTitle({
				title: this.i18n.tabBar.user
			});
			this.getdata();
		},
		methods: {
			//下拉加载
			loadmore() {
				console.log('下拉加载');
				let _self = this;
				_self.load_sta = true;
				_self.formData.page++;
				_self.getdata(_self.formData);
			},
			getdata(){
				getWebDatas().then(res =>{
					console.log(333,res)
					if(res.code === 2000){
						//this.datalist = res.data;
					}
				})
			},
			tohref(url,name){
				console.log(333,url);
				uni.navigateTo({
					url:'/pages/shopping/webView?url=' + url + '&name=' + name
				})
				//location.href = this.url;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
		background: $uni-bg-color;
		display: block;
		position: sticky;
		top: 0rpx;
		z-index: 9999;
		overflow: hidden
	}
	.box-img{
		width: 688rpx;
		height: 210rpx;
		margin-bottom: 30rpx;
	}
	.det-con-more {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 10rpx;
		color: #999;
		font-size: 24rpx;
	}

	.page-content {
		width: 100vw;
		height: 100%;
		background: $uni-bg-color;
		color: $font-color-w;
		padding: $page-row-spacing;

		//内容
		.page-body {
			height: 100%;
		}

		//头部
		.page-top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 30rpx;

			.t-logo {
				width: 239rpx;
				height: 40rpx;
			}

			.t-button {
				height: 50rpx;
				line-height: 50rpx;
				border-radius: 25rpx;
				padding: 0 20rpx;
				background: $uni-but-bg-color;
				font-size: $font-sm;
			}

			.t-tit {
				font-size: $font-base;
			}
		}
	}
</style>
